﻿using GDGeek;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MrPP.SerriedCabinet
{
    public class CellManager : GDGeek.Singleton<CellManager>
    {
        public enum Type { 
            Hlight,
            Check,
            Shelve,

        }

        public Action<Type> onState;
        public Func<Type> getState;
        private Type type_ = Type.Hlight;
        void Start()  
        {
            Model.Instance.search.onOpen += doOpen;
            getState =delegate { return type_; };
        }
        void OnDestroy() {
            if (Model.IsInitialized) { 
                Model.Instance.search.onOpen -= doOpen;
            }
        }

        private void doOpen(int arg1, int arg2)
        {
            switch (arg2) {
                case -1:
                case 0:
                    this.doHlight();
                    break;
                case 1:
                    this.doCheck();
                    break;
                case 2:
                    this.doShelve();
                    break;

            }
        }

        public void doShelve()
        {
            type_ = Type.Shelve;
            onState?.Invoke(type_);
        }

        public void doCheck()
        {

            type_ = Type.Check;
            onState?.Invoke(type_);
        }

        public void doHlight()
        {

            type_ = Type.Hlight;
            onState?.Invoke(type_);

        }

    }
}